<!-- File: /app/views/users/profile.ctp -->




<div class="users form">
    
	<h2>User Profile</h2>
	<table>
	<?php
        	if (file_exists('img/profile/user/' . $user['User']['id'] . '.jpg')) {
           		echo '<p>' . $this->Html->image('profile/user/' . $user['User']['id']. '.jpg', array('width' => '200')) . '</p>';
           	} else {
           		echo '<p>' . $html->image("default_user.jpg", array('width' => '200')) . '</p>';
           	}
           	echo $this->Html->tableCells(array('Name: ', $user['User']['first_name'] . ' ' . $user['User']['last_name']));
			echo $this->Html->tableCells(array('Email: ', $user['User']['email_addr']));
			echo $this->Html->tableCells(array('Tel:', $user['User']['phone']));
			echo $this->Html->tableCells(array('Address: ', $user['User']['addr1']));
			echo $this->Html->tableCells(array('', $user['User']['city'] . ', ' . $user['User']['state'] . ' ' . $user['User']['postal']));
			
			/*
			if ($user['User']['interests'] != null)
				echo $this->Html->tableCells(array('Interests:', $user['User']['interests']));
				*/
    ?>
    </table>
    
  
    
 	<?php 
 	$this->log($are_friends, 'debug');
 	if ($are_friends['result']) {
 		echo $this->Form->create('Wall', array('action'=>'write_post/'. $user['User']['id'],'enctype' => 'multipart/form-data'));
		echo $this->Form->input('post_content',array('label' => 'Write Something'));	
		echo $this->Form->end('Post');
	?>
	
 	<?php 
	if ($posts) {
		foreach ($posts as $post) {
			
	?>
		<div class="post_listing">
            <div class="post_listing_left">
            <?php
                    if (file_exists('img/profile/user/' . $post['Post']['poster_id'] . '.jpg')) {
                        echo $this->Html->image('profile/user/' . $post['Post']['poster_id'] . '.jpg', array('width' => '90'));
                    } else {
                        echo $this->Html->image('default_user.jpg', array('width' => '90'));
                    }
             ?>
            </div>
            <div class="post_listing_right">
            	<p><?php echo $post['User']['first_name'] . ' ' . $post['User']['last_name']; ?></p>
               	<p><?php echo $post['Post']['content']; ?></p>
                <p><?php echo $post['Post']['timestamp']; ?></p>
            </div>
            <div style="clear:both;"></div>
       </div>
	<?php }} else {?>
	<div class="wall_listing_no_post">
	<?php echo "<p >" . "there is no posts for " . $user['User']['first_name'] . "<p>" ;}?>
	</div>
	
	<?php };?>
	
 
    <div style="float:right;"></div>
    <div style="clear:both;"></div>
</div> <!-- <div> -->

<?php  //this section uses: users_controller >> function profile		
	echo '<div class="users form">';
			echo '<h1>User Blogs</h1>';
	if ($blogs != null) {		
					foreach($blogs as $blogKey => $blogValue) {		//blog KEY is blog ID, VALUE is the blog's subject
							echo $html->link($blogValue, array('controller' => 'blogs', 'action' => 'viewBlog/' .$blogKey));	
						echo '<br /><br />';
					} //end foreach
	}
	else {
		echo '<b>This User has no Blogs yet.</b>';
	}
	echo '</div>';
?>